The disclosure of the following priority application is incorporated herein by reference:
Japanese Patent Application No. 11-40813 filed Feb. 19, 1999.
1. Field of the Invention
The present invention relates to an image correction apparatus that corrects the gradation characteristics of an image and in particular, an image correction apparatus that performs a correction on an image whose quality has deteriorated due to poor illumination conditions, exposure conditions or the like during an image-capturing operation performed in an electronic camera that employs a solid image-capturing element or a camera that employs silver halide film. It also relates to a recording medium that stores an image correction program and can be read by a computer.
2. Description of the Related Art
Generally, an image captured by a camera, whether it is a monochrome image or a color image, is evaluated based upon the gradation (lightness) of the individual pixels. Monochrome gradation is used for a monochrome image and gradations of R (red), G (green) and B (blue), or C (cyan), M (magenta) and Y (yellow) or the like are used for a color image. Since image quality deteriorate due to certain photographing conditions, fading or the like, various methods are employed to perform image correction.
Gradation correction is an effective method of image correction, and gradation correction in the prior art is achieved by using a histogram that indicates gradient frequency distribution. Such a histogram is calculated as follows. The gradations of individual pixels constituting an image are detected, and the number of pixels (frequency) at each gradation of, for instance, 256 gradations, is calculated. A histogram is achieved by plotting the number of pixels (frequency) corresponding to each gradation.
In this image correction, the gradation distribution of an image is corrected by excluding ranges from the upper end (the maximum gradations) and the lower end (the minimum gradations) of the histogram to an extent corresponding to the numbers of pixels specified by the user as threshold values and then converting the histogram through the conversion formula in formula 1 in the prior art.
C(x)=n(xxe2x88x92a)/(bxe2x88x92a)xe2x80x83xe2x80x83formula 1 
In the formula above, x represents the gradations before correction, a represents the minimum value of the gradations before the correction, b represents the maximum value of the gradations before the correction, C(x) represents the gradations after the correction and n is the difference between the maximum gradation and the minimum gradation of the corrected image which is normally the maximum value, i.e., 255, of 8-bit data.
It can be clearly understood that the width of the gradation range in the poor image is expanded to 8 bits (256 gradations) through the correction achieved by using conversion formula 1.
Through this technology in the prior art, an image with poor contrast corresponding to the histogram in FIG. 4 is corrected in a satisfactory manner by correcting the histogram to achieve the histogram in FIG. 5. In other words, the technology in the prior art is effective as long as the histogram does not manifest a major constriction of gradation values.
However, an image photographed under certain illumination conditions and exposure conditions may not always be corrected in a satisfactory manner through the image correction method in the prior art. For instance, when photographing a person in strongly backlit conditions, a phenomenon whereby the image of the person is blacked out with the background being washed out often manifests. The histogram of such an image may be as shown in FIG. 6. FIG. 6 indicates that the number of pixels in the middle gradations is extremely low compared to that in the low gradations and the high gradations. Since the gradation width of this image is already close to 256, it is safe to conclude that the image cannot be adequately corrected by using formula 1 as in the prior art. Hardly any improvement is made with respect to the problem of image with undesirable black area or dark area due to underexposed image of the person and with undesirable white area or bright area due to the overexposed image of the background.
In addition, it is difficult to achieve an adequate correction when a wide gradation range with small numbers of pixels extends toward the lower end (generally, toward both the upper and lower ends) of the histogram, as illustrated in FIG. 7 as well. Namely, in the method in which the ranges extending from the upper end (the maximum gradation) and the lower end (the minimum gradation) of the histogram to points in the histogram specified by the user as threshold values (expressed as numbers of pixels) are excluded, an adequate image correction effect is not realized if the ratio of the numbers of pixels set for exclusion is low, e.g., if the ratio corresponding to the gradation at (L1) in FIG. 7 is set. In addition, if the ratio number of pixels set for exclusion is high, e.g., if the ratio corresponding to the gradation at (L2) in FIG. 7 is set, a problem arises in that a large portion of the gradation information in the original image is lost. Thus, it may not always be possible to specify correct threshold values when employing the method in the prior art.
An object of the present invention is to provide an image correction apparatus capable of correcting images that cannot be corrected by using the image correction method in the prior art and a recording medium that stores an image correction program and can be machine read.
In order to resolve the above mentioned problem, in the present invention, a threshold value is specified by the ratio of the number of pixels at one gradation against the total number of pixels and the image is corrected based upon comparison of the threshold value and the ratio at each gradation in the histogram. While in the image correction method in the prior art, a threshold value for cutting off the histogram is specified by the ratio of the accumulated number of pixels in the individual gradations starting from the upper end or the lower end of the histogram.
Accordingly, the object is achieved in the image correction apparatus according to the present invention by comprising an image intake unit that obtains image data from the outside, a histogram preparation unit that prepares a histogram by calculating the ratio of the number of pixels corresponding to each gradation against the total number of pixels based upon the image data and a gradation correction unit that corrects the gradation width of the histogram through comparison of a threshold value for the ratio of the number of pixels corresponding to one gradation determined through user specification and the ratio of the number of pixels corresponding to each gradation in the histogram.
The gradation correction unit is capable of correcting the gradation width of the histogram by compressing the width of gradations whose ratio of number of pixels is less than the threshold value in the histogram. It may compress the gradation width by excluding gradations whose ratio of numbers of pixels is less than the threshold value. The gradation width may be compressed at a compression rate that is in inverse proportion to the ratio of the number of pixels. The width of the gradation whose ratio of number of pixels is less than the threshold value may be compressed to the minimum gradation width, i.e., 1. In other words, if a plurality of gradations with ratios of numbers of pixels that are less than the threshold value are present continuously, the value achieved by integrating these numbers of pixels may be handled as the frequency corresponding to one gradation.
The threshold value may be expressed as a function (S(i)) of the gradation (i). In this case, the ratio of the number of pixels corresponding to each gradation in the histogram is compared against the threshold value S(i). This means that the threshold value (S) is varied in correspondence to the gradation (i) For instance, when correcting an image to be placed emphasis on the middle gradations, the threshold value (S) should be set low in the middle gradations with the threshold value (S) set to a large value in the low gradations and the high gradations.
In addition, the image correction apparatus may further comprise a full gradation expansion unit that expands the gradation width over the entire histogram.
In a recording medium according to the present invention that records the image correction program and can be machine read, a program comprising an image intake procedure in which image data are obtained from the outside, a histogram preparation procedure in which a histogram is prepared by calculating the ratio of the number of pixels corresponding to each gradation against a total number of pixels based upon the image data and a gradation correction procedure in which the gradation width of the histogram is corrected based upon comparison of a threshold value for the ratio of the number of pixels corresponding to a given gradation determined through user specification and the ratio of the number of pixels corresponding to each gradation in the histogram is stored. By setting the recording medium in a computer and loading the program, the computer is enabled to function as the image correction apparatus described earlier.